package com.ehl.capture.atest;

import com.ehl.capture.db.Config;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author Jiax
 * @version 1.0.0
 * @description: TestClass
 * @date 2024-05-18 07:03
 */

public class TestClass {
    public static void main(String[] args) {
        //scheduledTask();

        boolean flag = Boolean.parseBoolean(Config.getValue("zdkk.redischeck.flag"));
        if(flag){
            System.out.println("=======================");
        }
    }

    /**
     * 1、ScheduledExecutorService 执行定时任务
     */
    private static void scheduledTask() {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
        Runnable task = new Runnable() {
            @Override
            public void run() {
                // 需要定时执行的任务
                System.out.println(DateFormatUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss") + ".....Task executed");
            }
        };
        long initialDelay = 0; // 延迟0秒后执行任务
        long period = 10; // 每隔1000毫秒执行一次任务
        executorService.scheduleAtFixedRate(task, initialDelay, period, TimeUnit.SECONDS);
    }
}
